<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>地点列表</title>
<%@include file="/WEB-INF/views/include/easyuifile.jsp" %>
</head>
<body>

<div id="build-layout" class="easyui-layout" style="width:100%;margin: 0px; height: 800px;">
	<div data-options="region:'north',split:true,title:'组合查询',iconCls:'icon-search'" style="width:100%; height: 80px;padding: 5px 10px;">
		<form class="form-inline" id="form1">
			<div class="form-group">
				<label for="cityid">城市</label> 
				<select class="form-control"
					id="cityid" name="cityid" style="width:150px;">
					<option value="">全部</option>
					<c:forEach items="${citys}" var="city">
						<option value="${city.id}">${city.cityname }</option>
					</c:forEach>
				</select>
				<label for="placename">地名</label> <input type="text" class="form-control"
					id="placename" name="placename" style="width:120px;">
				<button type="button" class="btn btn-info" onclick="doSearch()">查询</button>
			</div>
		</form>
	</div>
	<div data-options="region:'center'"  class="table-responsive" style="margin-top:10px;border:none;">
		<table id="dg" class="easyui-datagrid" style="width:100%;">
		</table>
	</div>
	<div id="toolbar">
		<shiro:hasPermission name="fantasy:citybuild:edit">
		<a href="javascript:void(0)" class="easyui-linkbutton" plain="true" 
				iconCls="icon-add"  onclick="addCityMap();">地点添加</a>
		</shiro:hasPermission>
</div>  
</div>
</body>
<script type="text/javascript">
	//组织查询参数
	function getQueryParams() {
		var params = {
			cityid : $("#cityid").val(),
			placename : $("#placename").val()
		};
		return params;
	}
	
	//查询
	function doSearch() {
		$("#dg").datagrid("load", getQueryParams());
	}

	$(function() {
		//地点列表
		$("#dg").datagrid({
			fitColumns:true,
			width : "100%",
			height : 570,
			queryParams : getQueryParams(),
			singleSelect : true,
			url : "${ctx}/fantasy/cityBuild/getCityMapData.do",
			method : "post",
			toolbar:'#toolbar',
			pagination : true,
			nowrap : false,
	        autoRowHeight: false,
	        striped: true,
			rownumbers : true,
			pageSize : 20,
			pageList : [ 10, 20, 30, 40, 50 ],
			idField : "id",
			frozenColumns : [ [ {
				field : "id",
				width : 230,
				title : "编号",
				align:'center'
			}, {
				field : "placename",
				width : 130,
				title : "地名",
				align:'center'
			} ] ],
			columns : [ [
				{
					field : "cityname",
					width : 130,
					title : "所属城市",
					align:'center'
				},
				{
					field : "placedesc",
					width : 400,
					title : "简介",
					align:'left'
				},
				{
					field : "updateBy",
					width : 100,
					title : "更新者",
					align:'left',  
				  	formatter:function(val, row, index){  
					    if(row.updateBy){  
					      return  row.updateBy.name;  
					    }  
					}
				},
				{
					field : "updateDate",
					width : 100,
					title : "更新日期",
					align:'left',
					formatter : dateTimeFun
				},
				{
					field : "修改",
					width : 80,
					title : "操作",
					formatter : function(v, r, i) {
            			return "<a href=\"javascript:;\" onclick=\"javascript:editCityMap('"+i+"');\">查看</a>&nbsp;<shiro:hasPermission name='fantasy:citybuild:edit'><a href=\"javascript:;\" onclick=\"javascript:editCityMap('"+i+"');\">修改</a></shiro:hasPermission>";
					},
					align:'center'
				}
				
			] ],
			onLoadSuccess : function(data) {
			}
		});
	});
	
	//修改地点信息
	function editCityMap(index){ 
		$('#dg').datagrid('selectRow',index);// 关键在这里  
		var row = $('#dg').datagrid('getSelected');  
		if (row){
	    	parent.layer.open({
				type: 2,
				area: [800+'px', 550+'px'],
				fix: false, //不固定
				shade:0.4,
				title:"修改地点信息",
				content: "${ctx}/fantasy/cityBuild/toEditCityMap?city.id=" + row.cityid + "&id="+row.id,
				success: function(layero, index){
			  	}
			});
		}  
	}
	//增加地点信息
	function addCityMap(){
		parent.layer.open({
	        type: 2,
	        shade: 0.4,
	        title: '增加地点信息',
	        content:'${ctx}/fantasy/cityBuild/toNewCityMap',
	        area: ['800px', '450px'],
	        
		});
	}
</script>
</html>